//========================================================================
//Copyright 2007-2010 David Yu dyuproject@gmail.com
//------------------------------------------------------------------------
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at 
//http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//========================================================================

package com.dyuproject.kvstore;

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.google.common.base.Preconditions;

/**
 * Base class for stores. 
 *
 * @author David Yu
 * @created Feb 4, 2010
 */
public abstract class AbstractStore<T> implements Store<T>
{
    
    protected final Serializer<T> serializer;
    
    public AbstractStore(Serializer<T> serializer)
    {
        Preconditions.checkNotNull(serializer);
        this.serializer = serializer;
    }
    
    public final Serializer<T> getSerializer()
    {
        return serializer;
    }
    
    public T get(String key)
    {
        return get(key, serializer);
    }

    public List<T> get(List<String> keys)
    {
        return get(keys, serializer);
    }

    public List<Entry<String, T>> getEntries(List<String> keys)
    {
        return getEntries(keys, serializer);
    }

    public List<Map.Entry<String, T>> scanEntries(String start, String end, int max)
    {
        return scanEntries(start, end, max, serializer);
    }

    public List<Map.Entry<String, T>> scanEntriesReverse(String start, String end, int max)
    {
        return scanEntriesReverse(start, end, max, serializer);
    }

    public List<T> scan(String start, String end, int max)
    {
        return scan(start, end, max, serializer);
    }

    public List<T> scanReverse(String start, String end, int max)
    {
        return scanReverse(start, end, max, serializer);
    }

}
